<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 数组迭代
        let arr = [1, 2, 3, 4]
        let iter = arr[Symbol.iterator]();//迭代器对象
        // console.log(iter);

        console.log(iter.next().value);//1 迭代器输出第一个

        let rel = iter.next();
        console.log(rel.value, rel.done);//1
        // rel = iter.next()
        // console.log(rel.value, rel.done);//2
        // rel = iter.next()
        // console.log(rel.value, rel.done);//3
        // rel = iter.next()
        // console.log(rel.value, rel.done);//4


        // done 是对象包含属性，用于判断是否遍历结束;当 done 为 true 时则遍历结束
        // let rel = iter.next()
        // while (!rel.done) {
        //   console.log(rel.value, rel.done);
        //   rel = iter.next()
        // }

        // 简化迭代, 默认会调用迭代器的next方法的value 与 iter.next().value 等同
        for (const item of iter) {
            console.log(item);
        }

        //set迭代
        let set=new Set(['wer','123','y7u']);

    </script>
</body>

</html>